package postService

import (
	"errors"

	"notabug.org/ropemann/imabon/src/entities/post"
)

// FUCKING GAME CHANGER:
// https://www.youtube.com/watch?v=LEnXBueFBzk

var CreatePost = post.CreatePost
var DeletePost = post.DeletePost

func Create(board, thread string, newPost post.Post) (int64, error) {
	if len(newPost.Body) == 0 {
		return 0, errors.New("comment is empty")
	}

	affected, err := CreatePost(board, thread, &newPost)
	if err != nil || affected == 0 {
		return 0, err
	}
	return affected, nil
}

func Delete(board, threadId, postId string) (int64, error) {
	res, err := DeletePost(board, threadId, postId)

	return res, err
}
